﻿using System.Diagnostics.Contracts;
using AutomaTones.Model.Automaton_Model;
using Microsoft.Pex.Framework;

namespace AutomaTones.Model.Tools
{
    /// <summary>
    /// Conversions tools.
    /// </summary>
    /// <author>Anders Bech Mellson, anbh@itu.dk</author>
    [PexClass]
    partial class Convertor
    {
        /// <summary>
        /// Converts a Cellular Automaton to a State[,] grid.
        /// </summary>
        [PexMethod]
        public static State[,] CAToStateGrid(CellularAutomaton ca) {
            Contract.Requires(ca!=null);
            uint size = ca.DimensionSize;
            State[,] stateGrid = new State[size,size];
            for (int x = 0; x < size; x++)
                for (int y = 0; y < size; y++)
                    stateGrid[x, y] = ca.GetCell(x,y).State;
            return stateGrid;
        }
    }
}
